﻿#include "InstructionTurnTablePowerOn.h"

#include "ScriptRunner.h"
#include "TurnTableCodec.h"
#include "StateChecker.h"
#include "Device.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionTurnTablePowerOn,ScriptInstruction::Instruction_TurnTable_PowerOn,&InstructionTurnTablePowerOn::fromByteArray1);

InstructionTurnTablePowerOn::InstructionTurnTablePowerOn()
{
  instructionFlag = Instruction_TurnTable_PowerOn;
}

InstructionTurnTablePowerOn::InstructionTurnTablePowerOn(InstructionTurnTablePowerOn const& instructionTurnTablePowerOn)
{
  *this=instructionTurnTablePowerOn;
}

InstructionTurnTablePowerOn& InstructionTurnTablePowerOn::operator=(InstructionTurnTablePowerOn const & instructionTurnTablePowerOn)
{
  *(ScriptInstruction*)this=instructionTurnTablePowerOn;
  return *this;
}

InstructionTurnTablePowerOn::~InstructionTurnTablePowerOn()
{}

void InstructionTurnTablePowerOn::run()
{
  scriptRunner->sendInstruction(deviceId,TurnTableCodec::TurnTable_PowerOn);
  StateChecker<bool>::next_ifConditionReached(&Device::getTurnTable_runningState_power,
                                              true,
                                              deviceId,
                                              scriptRunner);
}

QString InstructionTurnTablePowerOn::toString()
{
  return QStringLiteral("转台上电");
}

QByteArray InstructionTurnTablePowerOn::toByteArray()
{
  return ScriptInstruction::toByteArray();
}

ScriptInstruction* InstructionTurnTablePowerOn::fromByteArray1(char * const src,int size,int * offset)
{
  (void)src;
  (void)size;
  (void)offset;
  return new InstructionTurnTablePowerOn();
}
